﻿Namespace Controls
    Public Class NumericTextBoxDecimal
        Inherits TextBox
        Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
            If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) AndAlso e.KeyChar <> "."c Then
                e.Handled = True
            End If

            ' only allow one decimal point
            If e.KeyChar = "."c AndAlso Me.Text.IndexOf("."c) > -1 Then
                e.Handled = True
            End If
        End Sub
    End Class
End Namespace